package com.guyaogg.gulimall.product.entity;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.guyaogg.common.valid.annotation.ListValue;
import com.guyaogg.common.valid.annotation.UpdateName;
import com.guyaogg.common.valid.group.AddGroup;
import com.guyaogg.common.valid.group.UpdateGroup;
import lombok.Data;
import org.hibernate.validator.constraints.URL;

import javax.validation.constraints.*;
import java.io.Serializable;

/**
 * 品牌
 * 
 * @author guyao
 * @email 3039744913@qq.com
 * @date 2021-10-08 15:51:59
 */
@Data
@TableName("pms_brand")
public class BrandEntity implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 * 品牌id
	 */
	@NotNull(message = "修改必须指定品牌 id ",groups = UpdateGroup.class)
	@Null(message = "新增不能指定品牌 id ",groups = AddGroup.class)
	@TableId
	private Long brandId;
	/**
	 * 品牌名
	 */
	@UpdateName(message = "品牌名不能修改为空",groups = UpdateGroup.class)
	@NotBlank(message = "品牌名不能为空",groups = AddGroup.class)
	private String name;
	/**
	 * 品牌logo地址
	 */
	@NotEmpty(message = " logo 地址不能为空",groups = AddGroup.class)
	@URL(message = " logo 必须是一个合理的 url 地址",groups = {UpdateGroup.class,AddGroup.class})
	private String logo;
	/**
	 * 介绍
	 */
	private String descript;
	/**
	 * 显示状态[0-不显示；1-显示]
	 */
//	@Min(value = 0,message = "显示状态只能只 0 或 1 字段")
//	@Max(value = 1,message = "显示状态只能只 0 或 1 字段")
	@TableLogic
	@NotNull(message = "显示状态不能为空",groups = AddGroup.class)
	@ListValue(value={0,1},message = "显示状态必须为 0 或 1",groups = {UpdateGroup.class,AddGroup.class})
	private Integer showStatus;
	/**
	 * 检索首字母
	 */
	@NotNull(message = "检索首字母不能为空",groups = AddGroup.class)
	@Pattern(regexp = "^[a-zA-Z]$",message = "检索首字母必须是一个字母",groups = {UpdateGroup.class,AddGroup.class})
	private String firstLetter;
	/**
	 * 排序
	 */
	@NotNull(message = "排序字段不能为空",groups = AddGroup.class)
	@Min(value = 0,message = "排序字段必须大于等于零",groups = {UpdateGroup.class,AddGroup.class})
	private Integer sort;

}
